#include <bits/stdc++.h>

using namespace std;

struct node
{
    int isnum;
    int num;
    char c;
};

string s;
stack<node>st;
queue<node>q;

map<char,int>priority;

void change(){
    int index=0,size=s.size();
    while(index<size){
        node t;
        char c = s[index];
        if(isdigit(c)){
            t.isnum=1;
            t.num=c-'0';
            q.push(t);
        }else{
            while(!st.empty()&&priority[st.top().c]<=priority[c]){
                q.push(st.top());
                st.pop();
            }
            t.isnum=0;
            t.c = c;
            st.push(t);
        }
        ++index;
    }
    while(!st.empty()){
        q.push(st.top());
        st.pop();
    }
}

int judge(){
    change();
    int ans;
    while(!q.empty()){
        if(q.front().isnum == 1){
            st.push(q.front());
        }else{
            node t;
            t.isnum = 1;
            int b=st.top().num;st.pop();
            int a=st.top().num;st.pop();
            // printf("b = %d, a = %d\n",b,a );
            switch(q.front().c){
                case 'x':
                    t.num = a*b;
                    break;
                case '/':
                    t.num = a/b;
                    break;
                case '+':
                    t.num = a+b;
                    break;
                case '-':
                    t.num = a-b;
                    break; 
            }
            st.push(t);
        }
        q.pop();
    }
    ans=st.top().num;
    // printf("ans = %d\n", ans);
    if(ans == 24)return 1;
    else return 0;
}

int main(int argc, char const *argv[])
{
    priority['x'] = 1;
    priority['/'] = 1;
    priority['+'] = 2;
    priority['-'] = 2;
    int n;scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        cin>>s;
        while(!st.empty())st.pop();
        if(judge()){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
    return 0;
}